<?php

/**
 * StaticPage filter form base class.
 *
 * @package    myarticles
 * @subpackage filter
 * @author     Apul Gupta<apulmca2k4@gmail.com>
 */
abstract class BaseStaticPageFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'title'            => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'url_slug'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'meta_title'       => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'meta_keyword'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'meta_description' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'content'          => new sfWidgetFormFilterInput(),
      'created_by'       => new sfWidgetFormPropelChoice(array('model' => 'User', 'add_empty' => true)),
      'created_at'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'updated_at'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'is_active'        => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
    ));

    $this->setValidators(array(
      'title'            => new sfValidatorPass(array('required' => false)),
      'url_slug'         => new sfValidatorPass(array('required' => false)),
      'meta_title'       => new sfValidatorPass(array('required' => false)),
      'meta_keyword'     => new sfValidatorPass(array('required' => false)),
      'meta_description' => new sfValidatorPass(array('required' => false)),
      'content'          => new sfValidatorPass(array('required' => false)),
      'created_by'       => new sfValidatorPropelChoice(array('required' => false, 'model' => 'User', 'column' => 'id')),
      'created_at'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'updated_at'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'is_active'        => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
    ));

    $this->widgetSchema->setNameFormat('static_page_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'StaticPage';
  }

  public function getFields()
  {
    return array(
      'id'               => 'Number',
      'title'            => 'Text',
      'url_slug'         => 'Text',
      'meta_title'       => 'Text',
      'meta_keyword'     => 'Text',
      'meta_description' => 'Text',
      'content'          => 'Text',
      'created_by'       => 'ForeignKey',
      'created_at'       => 'Date',
      'updated_at'       => 'Date',
      'is_active'        => 'Boolean',
    );
  }
}
